#include "../ThreadPool.h"
//#include "../CountDownLatch.h"
//#include <boost/thread/executors/basic_thread_pool.hpp>

#include <boost/bind.hpp>
#include <stdio.h>

void print()
{
	printf("tid=%d\n", boost::this_thread::get_id()/*cvs::CurrentThread::tid()*/);
}

void printString(const std::string& str)
{
	printf("tid=%d, str=%s\n", boost::this_thread::get_id()/*cvs::CurrentThread::tid()*/, str.c_str());
}

int main()
{
	cvs::ThreadPool pool("MainThreadPool");
	pool.start(5);

	pool.run(print);
	pool.run(print);
	for (int i = 0; i < 100; ++i)
	{
		char buf[32];
		sprintf(buf, "task %d", i);
		pool.run(boost::bind(printString, std::string(buf)));
	}

	//muduo::CountDownLatch latch(1);
	//pool.run(boost::bind(&muduo::CountDownLatch::countDown, &latch));
	//latch.wait();
	//boost::this_thread::sleep(boost::posix_time::seconds(5));
	pool.stop();

	return 0;
}

